package com.efeichong.common.utils;

import com.efeichong.common.exception.CustomException;
import com.efeichong.common.exception.LoginExpiredException;
import com.efeichong.enums.ResultEnum;

import java.util.function.Supplier;


/**
 * @author lxk
 * @date 2021/4/1
 * @description option为空时抛出CustomException
 */
@FunctionalInterface
public interface OptionEmptyFunction {

    static Supplier create(Integer status, String msg) {
        return () -> new CustomException(status, msg);
    }

    static Supplier createTokenExpired() {
        return () -> new LoginExpiredException();
    }

    static Supplier createDateNotExist() {
        return () -> new CustomException(ResultEnum.DATA_NOT_EXIST.getMessage());
    }

    static Supplier create(String msg) {
        return () -> new CustomException(msg);
    }

    static Supplier create() {
        return createDateNotExist();
    }

    void get();
}
